package com.gis;

import org.apache.hadoop.io.Writable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

/**
 * @author leon
 * @ClassName beans.java
 * @createTime 2021年09月26日 11:51:00
 */
public class beans implements Writable, Comparable<beans>{
    // 412206940	1596211215	7.2	121.934538	38.945422
    private String mmsi;
    private Long unixTime;
    private Double speed;
    private Double lon_d;
    private Double lat_d;

    public beans() {
    }

    public beans(String mmsi, Long unixTime, Double speed, Double lon_d, Double lat_d) {
        this.mmsi = mmsi;
        this.unixTime = unixTime;
        this.speed = speed;
        this.lon_d = lon_d;
        this.lat_d = lat_d;
    }

    public String getMmsi() {
        return mmsi;
    }

    public void setMmsi(String mmsi) {
        this.mmsi = mmsi;
    }

    public Long getUnixTime() {
        return unixTime;
    }

    public void setUnixTime(Long unixTime) {
        this.unixTime = unixTime;
    }

    public Double getSpeed() {
        return speed;
    }

    public void setSpeed(Double speed) {
        this.speed = speed;
    }

    public Double getLon_d() {
        return lon_d;
    }

    public void setLon_d(Double lon_d) {
        this.lon_d = lon_d;
    }

    public Double getLat_d() {
        return lat_d;
    }

    public void setLat_d(Double lat_d) {
        this.lat_d = lat_d;
    }

    @Override
    public String toString() {
        return mmsi +
                "," + unixTime +
                "," + speed +
                "," + lon_d +
                "," + lat_d;
    }


    @Override
    public int compareTo(beans o) {
        long l = this.getUnixTime() - o.getUnixTime();

        return (int) l;
    }

    @Override
    public void write(DataOutput dataOutput) throws IOException {

        dataOutput.writeUTF(mmsi);

        dataOutput.writeLong(unixTime);

        dataOutput.writeDouble(speed);
        dataOutput.writeDouble(lon_d);
        dataOutput.writeDouble(lat_d);

    }

    @Override
    public void readFields(DataInput dataInput) throws IOException {

        this.mmsi = dataInput.readUTF();
        this.unixTime = dataInput.readLong();
        this.speed = dataInput.readDouble();
        this.lon_d = dataInput.readDouble();
        this.lat_d = dataInput.readDouble();

    }
}
